package Askgene::Controller::Queue;

use strict;
use warnings;

use aliased 'Reaction::UI::ViewPort::ActionForm';
use aliased 'Askgene::InterfaceModel::Action::Queue::Item::Add';

use base qw/Askgene::Base::Controller/;

sub queue : Chained('base') PathPart('') CaptureArgs(0) {
    my ( $self, $c ) = @_;
    my $queue : Stashed = $c->model('Queue');
}

sub add : Chained('queue') PathPart('job/add') Args(0) {
    my ( $self, $c ) = @_;
    my $queue : Stashed;
    $self->push_viewport( ActionForm,
        action => Add->new(
            target_model => $queue,
            ctx          => $c,
            on_apply_callback =>
              sub { $self->after_upload_callback( $c => @_ ) }
        )
    );
}

sub after_upload_callback {
    my ( $self, $c, $vp, $job ) = @_;
    $c->log->debug($job->jobid);
}

1;
